/*
 * @Description: 权限按钮
 * @Author: ldx
 * @Date: 2022-09-18 21:25:05
 * @LastEditors: ldx
 * @LastEditTime: 2022-09-18 21:42:50
 */
import { Button } from 'antd'
import { ButtonProps } from 'antd/lib/button/button'
import { useRecoilValue } from 'recoil'

import { commonState } from '@/recoil'
type Props = {
  auth: string[]
} & ButtonProps
const AuthButton: React.FC<Props> = ({ auth = [], ...props }) => {
  const auths = useRecoilValue<string[]>(commonState.auths)
  return (
    <Button
      disabled={auth.every((auth) => !auths.includes(auth))}
      {...props}
    ></Button>
  )
}
export default AuthButton
